<template>
  <div class="order" v-if="orderlist.length!==0">
    <van-nav-bar title='订单'/>
    <order-item :orderlist='orderlist'/>
  </div>
</template>

<script>
import {NavBar } from 'vant'
import OrderItem from "./orderChild/orderItem";
export default {
  name: "order",
  components: {
    OrderItem,
    [NavBar.name]:NavBar
  },
  data() {
    return {
      orderlist: []
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    getData() {
      axios(`/api/user/orders/${localStorage.token}`).then(res => {
        let arr=res.orderlist.splice(8)
        this.orderlist =arr[0]
      });
    }
  }
};
</script>

<style scoped>
.order{
  height:100vh;
  width: 100%;

}
.van-nav-bar{
  background-color: #009eef;
}
.van-nav-bar__text,.van-nav-bar .van-icon{
  color: #fff;
} 
</style>